<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitUpdate44 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('package_skus', function (Blueprint $table) {
            $table->dropColumn(['activity_type', 'activity_id']);
        });

        Schema::table('order_skus', function (Blueprint $table) {
            $table->dropColumn(['activity_type', 'activity_id', 'product_id', 'product_uuid']);
        });

        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn(['activity_type', 'activity_id', 'activity_status']);

            $table->dropColumn(['client_name', 'client_type', 'os_type', 'score_reward', 'return_money', 'return_score', 'return_redpack']);
        });

        Schema::table('package_assets', function (Blueprint $table) {
            $table->dropColumn(['activity_type', 'activity_id']);
        });

        Schema::table('package_assets', function (Blueprint $table) {
            $table->integer('activity_id')->index()->nullable()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('activity_type', 20)->index()->nullable()->comment('对应活动类型, seckill groupon 等');
            $table->uuid('activity_uuid')->nullable()->comment('活动uuid');

            $table->integer('node_id')->nullable()->index()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('node_type', 20)->nullable()->index()->comment('对应实体类型,  product box yifanshang lottery egg_lottery');
            $table->uuid('node_uuid')->nullable()->comment('活动uuid');
        });

        Schema::table('package_skus', function (Blueprint $table) {
            $table->integer('activity_id')->index()->nullable()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('activity_type', 20)->index()->nullable()->comment('对应活动类型, seckill groupon 等');
            $table->uuid('activity_uuid')->nullable()->comment('活动uuid');

            $table->integer('node_id')->nullable()->index()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('node_type', 20)->nullable()->index()->comment('对应实体类型,  product box yifanshang lottery egg_lottery');
            $table->uuid('node_uuid')->nullable()->comment('活动uuid');
        });

        Schema::table('order_skus', function (Blueprint $table) {
            $table->integer('activity_id')->index()->nullable()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('activity_type', 20)->index()->nullable()->comment('对应活动类型, seckill groupon 等');
            $table->uuid('activity_uuid')->nullable()->comment('活动uuid');

            $table->integer('node_id')->nullable()->index()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('node_type', 20)->nullable()->index()->comment('对应实体类型,  product box yifanshang lottery egg_lottery');
            $table->uuid('node_uuid')->nullable()->comment('活动uuid');
        });

        Schema::table('orders', function (Blueprint $table) {
            $table->integer('activity_id')->index()->nullable()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('activity_type', 20)->index()->nullable()->comment('对应活动类型, seckill groupon 等');
            $table->uuid('activity_uuid')->nullable()->comment('活动uuid');

            $table->integer('node_id')->nullable()->index()->comment('活动id，盲盒id、一番赏id、抽奖id、扭蛋机id'); // 用户id
            $table->char('node_type', 20)->nullable()->index()->comment('对应实体类型,  product box yifanshang lottery egg_lottery');
            $table->uuid('node_uuid')->nullable()->comment('活动uuid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('package_skus', function (Blueprint $table) {
            // $table->dropColumn(['last_stock_all_pick_enable']);
        });

        Schema::table('order_skus', function (Blueprint $table) {
            // $table->dropColumn(['last_stock_all_pick_enable']);
        });
    }
}
